package com.health.system.service.system.impl;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;


import com.health.system.javacommon.base.BaseManager;
import com.health.system.javacommon.base.EntityDao;
import com.health.system.model.system.*;
import com.health.system.dao.system.*;
import com.health.system.service.system.impl.*;
import com.health.system.service.system.*;

@Component("rolePermissionManager")
@Transactional
public class RolePermissionManagerImpl extends BaseManager<RolePermission,java.lang.String> 
					implements RolePermissionManager {

	private RolePermissionDao rolePermissionDao;
	/**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性*/
	public void setRolePermissionDao(RolePermissionDao dao) {
		this.rolePermissionDao = dao;
	}
	public EntityDao getEntityDao() {
		return this.rolePermissionDao;
	}
	
	@Transactional(readOnly=true)
	public Page findByPageRequest(PageRequest pr) {
		return rolePermissionDao.findByPageRequest(pr);
	}
	
	public List getRolePermissionList(RolePermission rolepermission) {
		return rolePermissionDao.getRolePermissionList(rolepermission);
	}
	
	public List getPermissionList(Permission permission) {
		return rolePermissionDao.getPermissionList(permission);
	}
 
	public Boolean  deletesave(RolePermission u) {
		Boolean result =false;
		int i =-1,j =-1,size=u.getPermissionList().size();
		i =rolePermissionDao.delete(u);
		
		
		if(i>-1){
			j =rolePermissionDao.saverolepermissionlist(u);
		}
		if(j==size){
			result =true;
		}else{
			throw new RuntimeException();
		}
		return result;
	}
	/**
	 * 查询当前操作员角色对应的权限ID集合
	 * @param map
	 * String sort 权限类型
	 * String userId 操作员ID
	 * @return List<RolePermission>
	 */
	public List getPermissionByMap(Map map) {
		return rolePermissionDao.getPermissionByMap(map);
	}
}
